#ifdef ENABLE_NETWORK
#include "NumberKeyBoardEvent.h"
#include "Network_SetupEvent.h"
//#include "WinHomeEvent.h"
//#include "CardMultiUpEvent.h"
//#include "Menu_ID_Define.h"
#include "user.h"
#include "../aw_config.h"
#ifndef IW_ESSID_MAX_SIZE
#define IW_ESSID_MAX_SIZE 42
#endif
#define BLACK_COLOUR 4
extern struct iwscan_state *Scan_Result;
static char ptr_ip_addr[41];
static char mask_addr[41];
static char gateway_addr[41];
static char pridns_addr[41];
static char secdns_addr[41];
extern char output_point[IW_ESSID_MAX_SIZE + 1];
#include "../aw_network.h"
INT8U top_place_flag=0;
INT8U focus_flag=1;
INT8U top_length[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
INT8U output_string_length=0;
extern unsigned char output_string[IW_ENCODING_TOKEN_MAX + 1];
extern INT8U keyboard_parent_flag;//0 menu kodakgallery, 1 menu internet 2 menu Enable 1, 3 menu Enable2
extern INT8U key_menu_flag;
extern struct kodak_netif_setting kodak_network_config;
extern struct kodak_iw_config     kodak_wireless_config;
static struct netif_config temp_ifconfig;
static INT8U get_netconfig_flag = 0;

void UpdateAddrArrange(char *addr)
{
	char *p_str = NULL,*q_str = NULL;
	char temp_addr[20];	
	INT16U str_len;
	int i = 3;
	if(!addr)
		return;	
	str_len = strlen(addr);
	strcpy(temp_addr,addr);	
	temp_addr[str_len]  = 0;
	strcpy((char *)output_string,addr);
	output_string_length = str_len;
	output_string[output_string_length] = 0;
	//p_str = strrchr(temp_addr,'.');
	//if(p_str)
	top_place_flag = 3;
	p_str = strrchr(temp_addr,'.');
	if(p_str){
		strcpy(number_key_str[3],&p_str[1]);
		top_length[3] = strlen(number_key_str[3]);
		strcat(number_key_str[3],"|");
		*p_str = 0;
	}
	p_str = strrchr(temp_addr,'.');
	if(p_str){
		strcpy(number_key_str[2],&p_str[1]);
		top_length[2] = strlen(number_key_str[2]);
		*p_str = 0;
	}
	p_str = strrchr(temp_addr,'.');
	if(p_str){
		strcpy(number_key_str[1],&p_str[1]);
		top_length[1] = strlen(number_key_str[1]);
		*p_str = 0;
	}
	p_str = &temp_addr[0];
	strncpy(number_key_str[0],p_str,3);
	q_str = strchr(number_key_str[0],'.');
	if(q_str)
		*q_str = 0;
	top_length[0] = strlen(number_key_str[0]);
}

void CheckIpAddr(char *addr_str,INT8U arrage_len)
{
	INT8U i;
	INT16U str_len,total_len;
	total_len = strlen(addr_str);
	for(i = 0;i<4;i++){
		str_len = strlen(number_key_str[i]);
		//if((top_length[i] == 0)||(str_len == 0)){
		if(str_len == 0){
			if(total_len<arrage_len){
				if((addr_str[total_len -1] == '.')||(total_len == 0)){
					strcat(addr_str,"0");
					total_len += 1;
				}
				else
				{
					strcat(addr_str,".0");
					total_len += 2;
				}
			}
		}
	}
}

void PressNumberKeyBackDone()
{
	
	GUIShowWindow("Network_Setup");
	return;
	#if 0
	switch(keyboard_parent_flag)
	{
	    case 2:
	    	//PresetMenuEnable(ID_MENU_DYNAMIC_STATIC_IP);
	    	//GUIShowWindow("WinSelect");
	    	break;
	}
      #endif	
}
void GetKeyFocus(PHWND hwnd)
{
	PIXELVAL color_bk;
	color_bk=AWSetForeground(BLACK_COLOUR);
	switch(focus_flag)
	{
		
		case 10:
		case 11:
		case 12:
			hwnd->draw_info[17+focus_flag].draw_data = (INT32U)ICON_NUMKEY_LONG_FOCUS;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag) ;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag+29) ;
      			hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
			break;

		
		default:
			hwnd->draw_info[17+focus_flag].draw_data = (INT32U)ICON_NUMKEY_SHORT_FOCUS;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag) ;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag+29) ;
      			hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
			break;
	}
	AWSetForeground(color_bk);
}
void GetKeyLose(PHWND hwnd)
{
	PIXELVAL color_bk;
	color_bk=AWSetForeground(BLACK_COLOUR);
	switch(focus_flag)
	{        
	
		case 10:
		case 11:
		case 12:
			hwnd->draw_info[17+focus_flag].draw_data = (INT32U)ICON_NUMKEY_LONG_LOSE;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag) ;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag+29) ;
      			hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
			break;

			
		default:
			hwnd->draw_info[17+focus_flag].draw_data = (INT32U)ICON_NUMKEY_SHORT_LOSE;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag) ;
	    		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 17+focus_flag+29) ;
      			hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
			break;
	}
	AWSetForeground(color_bk);
}
void PressEnterDown(PHWND hwnd)
{
	PIXELVAL color_bk;
	color_bk=AWSetForeground(BLACK_COLOUR); 		
	PHWND dir_hwnd=AWFindWinCtrlByName("NumberKeyBoard_Caption");
	INT32U width = dir_hwnd->draw_info[1].draw_width -10;
	int check_num = 0;
	INT16U check_len,i,j,temp_num;
   	switch(focus_flag)
   	{		
   	case 10:		//tab
   		if(top_place_flag<15)
   		{
   			number_key_str[top_place_flag][top_length[top_place_flag]]='\0';
			check_len = top_length[top_place_flag];
			if(check_len > 2){
				temp_num = 1;
                                check_num = 0;
				for(i = check_len;i>0;i--){
					check_num = (number_key_str[top_place_flag][i-1]-'0')*temp_num+check_num;
					temp_num = temp_num * 10;
				}
				if(check_num > 255){
					number_key_str[top_place_flag][0] = '0';
					number_key_str[top_place_flag][1] = '0';
					number_key_str[top_place_flag][2] = '0';
					output_string[output_string_length-3] = '0';
					output_string[output_string_length-2] = '0';
					output_string[output_string_length-1] = '0';
				}
			}
			if(check_len == 0){
				number_key_str[top_place_flag][0] = '0';
				top_length[top_place_flag]++;
				number_key_str[top_place_flag][top_length[top_place_flag]]='\0';
				output_string_length ++;
				output_string[output_string_length-1] = '0';
			}
   			top_place_flag++;
   			output_string_length++;
   			number_key_str[top_place_flag][0]='|';
   			output_string[output_string_length-1]='.';
   			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag) ;
	      		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, top_place_flag+1) ;
	      		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+29) ;
	      		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, top_place_flag+30) ;
        		hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
   		}
   		break;
   	case 12:		//back
   		if(top_length[top_place_flag]>0)
   		{
   			top_length[top_place_flag]--;
   			output_string_length--;
   			number_key_str[top_place_flag][top_length[top_place_flag]+1]='\0';
   			number_key_str[top_place_flag][top_length[top_place_flag]]='|';
   			output_string[output_string_length]='\0';
   			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+1) ;
	        	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+30) ;
          		hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
   		}
   		else if(top_place_flag>0)
   		{
   			top_place_flag--;
			top_length[top_place_flag]--;
   			output_string_length=top_length[top_place_flag];
   			number_key_str[top_place_flag+1][0]='\0';
   			number_key_str[top_place_flag][top_length[top_place_flag]]='|';
			output_string[0]=number_key_str[top_place_flag][0];
			output_string[1]=number_key_str[top_place_flag][1];
   			output_string[output_string_length]='\0';
   			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+1) ;
   			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+2) ;
	        	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+30) ;
	        	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+31) ;
          		hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
   		}
   		break;
   	case 11:  	//done
 
            for(i=0;i<16;i++)
            	{
                   for(j=0;j<3;j++)
                   	{
                        if(number_key_str[i][j]=='|')
							number_key_str[i][j]=0;
				    }
			    }
      
				 // IP address 
	         memset(output_string, 0, 16);
	         sprintf(output_string,"%s.%s.%s.%s",number_key_str[0],number_key_str[1],number_key_str[2],number_key_str[3]);  
		     if(output_string[0]>'9'||output_string[0]<'0')
   			break;
		      CheckIpAddr((char *)output_string,sizeof(output_string));
   		      strcpy(ptr_ip_addr,(char *)output_string);
   		      output_string_length=0;
   		      if (get_netconfig_flag)
   		      	{  
			        char mask_str[20];
                 		if (temp_ifconfig.netmask.s_addr)
	   		             {                        	
                    		inet_ntoa_r(temp_ifconfig.netmask, mask_str);
				            UpdateAddrArrange(mask_str);
                		 }
            	}
	  	  
				//Subnet Mask
	       memset(output_string, 0, 16);
	       sprintf(output_string,"%s.%s.%s.%s",number_key_str[4],number_key_str[5],number_key_str[6],number_key_str[7]); 
	       if(output_string[0]>'9'||output_string[0]<'0')
			    break;
	      CheckIpAddr((char *)output_string,sizeof(output_string));
		      strcpy(mask_addr,(char *)output_string);
		      output_string_length=0;
		  
		      if (get_netconfig_flag)
		      	 {  
		           char gateway_str[20];
             		if (temp_ifconfig.gateway.s_addr)
   		               {                        	
                		 inet_ntoa_r(temp_ifconfig.gateway, gateway_str);
			             UpdateAddrArrange(gateway_str);
            		    }
        	  }
	
		    //Default Gateway
          memset(output_string, 0, 16);
          sprintf(output_string,"%s.%s.%s.%s",number_key_str[8],number_key_str[9],number_key_str[10],number_key_str[11]); 
          if(output_string[0]>'9'||output_string[0]<'0')
		          break;
          CheckIpAddr((char *)output_string,sizeof(output_string));
	          strcpy(gateway_addr,(char *)output_string);
              output_string_length=0;
	     
               if (get_netconfig_flag)
		   	{  
	            char pdns_str[20];
         		if (temp_ifconfig.primary_dns.s_addr)
		                {                        	
            		    inet_ntoa_r(temp_ifconfig.primary_dns, pdns_str);
		                UpdateAddrArrange(pdns_str);
        		    }
    		}

		//DNS server

        memset(output_string, 0, 16);
        sprintf(output_string,"%s.%s.%s.%s",number_key_str[12],number_key_str[13],number_key_str[14],number_key_str[15]); 
        if(output_string[0]>'9'||output_string[0]<'0')
		       break;
        CheckIpAddr((char *)output_string,sizeof(output_string));
	        strcpy(pridns_addr,(char *)output_string);
	        output_string_length=0;

	      if (get_netconfig_flag)
	  	{  
	      char sdns_str[20];
            if (temp_ifconfig.secondary_dns.s_addr)
		             {                        	
            		inet_ntoa_r(temp_ifconfig.secondary_dns, sdns_str);
		            UpdateAddrArrange(sdns_str);
        		         }
    	 }	   	

	
		
   		output_string[output_string_length]='\0';
   		output_string_length=0;
   		Setup_Static_IP(ptr_ip_addr,mask_addr,gateway_addr, pridns_addr, 0);
		GUIShowWindow("Network_Setup");
   		break;
	
   		default:
   			if((top_place_flag>15)||((top_place_flag==15)&&top_length[top_place_flag]==3))
			{
   				break;
   			}
			else
   			{
   				top_length[top_place_flag]++;
   				output_string_length++;
   				output_string[output_string_length-1]=number_key_str[focus_flag+16][0];
   				number_key_str[top_place_flag][top_length[top_place_flag]-1]=number_key_str[focus_flag+16][0];
   				if(top_length[top_place_flag]<3||(top_place_flag==3)||(top_place_flag==7) ||(top_place_flag==11)|| (top_place_flag==15) )
   				{
					if(((top_place_flag==3)||(top_place_flag==7)||(top_place_flag==11))&&(top_length[top_place_flag]==3))
					{ 
					   number_key_str[top_place_flag+1][0]='|';
					}
                    else
					   number_key_str[top_place_flag][top_length[top_place_flag]]='|';
					
					check_len = top_length[top_place_flag];
					if(check_len > 2){
						temp_num = 1;
                                                check_num = 0;
						for(i = check_len;i>0;i--){
							check_num = (number_key_str[top_place_flag][i-1]-'0')*temp_num+check_num;
							temp_num = temp_num * 10;
						}
						if(check_num > 255){
							number_key_str[top_place_flag][0] = '0';
							number_key_str[top_place_flag][1] = '0';
							number_key_str[top_place_flag][2] = '0';
							output_string[output_string_length-3] = '0';
							output_string[output_string_length-2] = '0';
							output_string[output_string_length-1] = '0';
						}
					
				   if(top_place_flag==3)      // IP address 
				     {					     		
				     if(output_string[0]>'9'||output_string[0]<'0')
		   			break;
				      CheckIpAddr((char *)output_string,sizeof(output_string));
		   		      strcpy(ptr_ip_addr,(char *)output_string);
		   		      output_string_length=0;
		   		     // top_length[0]=0;
		   		      //top_length[1]=0;
		   		    //  top_length[2]=0;
		   		    //  top_length[3]=0;
		   		     // top_place_flag=4;
		   		      if (get_netconfig_flag)
		   		      	{  
					char mask_str[20];
                         		if (temp_ifconfig.netmask.s_addr)
			   		{                        	
                            		inet_ntoa_r(temp_ifconfig.netmask, mask_str);
						UpdateAddrArrange(mask_str);
                        		  }
                    		         }
				}
				   if(top_place_flag==7)                  //Subnet Mask
				     {					     		
				     if(output_string[0]>'9'||output_string[0]<'0')
		   			break;
				      CheckIpAddr((char *)output_string,sizeof(output_string));
		   		      strcpy(mask_addr,(char *)output_string);
		   		      output_string_length=0;
		   		  
		   		      //top_place_flag=8;
		   		      if (get_netconfig_flag)
		   		      	{  
					char gateway_str[20];
                         		if (temp_ifconfig.gateway.s_addr)
			   		{                        	
                            		inet_ntoa_r(temp_ifconfig.gateway, gateway_str);
						UpdateAddrArrange(gateway_str);
                        		           }
                    	                 	}
		   	
					}
				   if(top_place_flag==11)                 //Default Gateway
				     {					     		
				     if(output_string[0]>'9'||output_string[0]<'0')
		   			break;
				      CheckIpAddr((char *)output_string,sizeof(output_string));
		   		      strcpy(gateway_addr,(char *)output_string);
		   	              output_string_length=0;
		   		     
		   		      //top_place_flag=12;
		   	               if (get_netconfig_flag){  
					char pdns_str[20];
                         		if (temp_ifconfig.primary_dns.s_addr)
			   		{                        	
                            		inet_ntoa_r(temp_ifconfig.primary_dns, pdns_str);
						UpdateAddrArrange(pdns_str);
                        		}
                    		}
					}
				  if(top_place_flag==15)                  //DNS server
				     {					     		
				     if(output_string[0]>'9'||output_string[0]<'0')
		   			break;
				      CheckIpAddr((char *)output_string,sizeof(output_string));
		   		      strcpy(pridns_addr,(char *)output_string);
		   		       output_string_length=0;
		   		     
		   		    //  top_place_flag=0;
		   		      if (get_netconfig_flag){  
					char sdns_str[20];
                         		if (temp_ifconfig.secondary_dns.s_addr)
			   		{                        	
                            		inet_ntoa_r(temp_ifconfig.secondary_dns, sdns_str);
						UpdateAddrArrange(sdns_str);
                        		         }
                    		              }	   	
					}		
					hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+1) ;
	            			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+30) ;
              			        hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
					memset(output_string,0,sizeof(output_string));
					top_place_flag++;
				}	
   					hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+1) ;
	            			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+30) ;
              			        hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
              			        
   			               }
   			           else
   			           	{
   					number_key_str[top_place_flag][top_length[top_place_flag]]='\0';
					check_len = top_length[top_place_flag];
					if(check_len > 2)
					{
						temp_num = 1;
                                                check_num = 0;
						for(i = check_len;i>0;i--){
							check_num = (number_key_str[top_place_flag][i-1]-'0')*temp_num+check_num;
							temp_num = temp_num * 10;
						}
						if(check_num > 255){
							number_key_str[top_place_flag][0] = '0';
							number_key_str[top_place_flag][1] = '0';
							number_key_str[top_place_flag][2] = '0';
							output_string[output_string_length-3] = '0';
							output_string[output_string_length-2] = '0';
							output_string[output_string_length-1] = '0';
						}
					}
   			      		top_place_flag++;
   			      		output_string_length++;
   			      		number_key_str[top_place_flag][0]='|';
   			      		output_string[output_string_length-1]='.';
			   		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+0) ;
				      	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, top_place_flag+1) ;
				      	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO,top_place_flag+29) ;
				      	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, top_place_flag+30) ;
			        	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;
   				}
   			}
   			
   			break;
   			
   	}
   	AWSetForeground(color_bk);
}

INT32S NumberKeyBoard_CaptionOnShow(PHWND hwnd, INT32S lpParam)
{
	
	switch(key_menu_flag)
      	{
      		
      		case ID_MENU_MANUAL_IP_ADDRESS:
      			hwnd->draw_info[2].draw_data = (INT32U)NUMKEYBOARD_STR_MANUAL_IP;
      		  
      	    		break;
      	      	default:
      	      		break;	    	
      	}
    	return 0 ;
}
INT32S NumberKeyBoard_CaptionOnPaint(PHWND hwnd, INT32S lpParam)
{
	INT8U i;
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 0);
	PIXELVAL color_bk;
	color_bk=AWSetForeground(BLACK_COLOUR);
	for(i=0;i<3;i++)
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, i);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
	AWSetForeground(color_bk);
    	return 1 ;
    
}

INT32S NumberKeyBoardBarOnShow(PHWND hwnd, INT32S lpParam)
{
	top_length[0]=0;
	top_length[1]=0;
	top_length[2]=0;
	top_length[3]=0;
	top_length[4]=0;
	top_length[5]=0;
	top_length[6]=0;
	top_length[7]=0;
	top_length[8]=0;
	top_length[9]=0;
	top_length[10]=0;
	top_length[11]=0;
	top_length[12]=0;
	top_length[13]=0;
	top_length[14]=0;
	top_length[15]=0;
	
	
	top_place_flag=0;
	output_string_length=0;
	get_netconfig_flag = 0;
	memset(output_string,0,sizeof(output_string));
	memset(number_key_str[0],0,sizeof(number_key_str[0]));
	memset(number_key_str[1],0,sizeof(number_key_str[1]));
	memset(number_key_str[2],0,sizeof(number_key_str[2]));
	memset(number_key_str[3],0,sizeof(number_key_str[3]));
	memset(number_key_str[4],0,sizeof(number_key_str[4]));
	memset(number_key_str[5],0,sizeof(number_key_str[5]));
	memset(number_key_str[6],0,sizeof(number_key_str[6]));
	memset(number_key_str[7],0,sizeof(number_key_str[7]));
	memset(number_key_str[8],0,sizeof(number_key_str[8]));
	memset(number_key_str[9],0,sizeof(number_key_str[9]));
	memset(number_key_str[10],0,sizeof(number_key_str[10]));
	memset(number_key_str[11],0,sizeof(number_key_str[11]));
	memset(number_key_str[12],0,sizeof(number_key_str[12]));
	memset(number_key_str[13],0,sizeof(number_key_str[13]));
	memset(number_key_str[14],0,sizeof(number_key_str[14]));
	memset(number_key_str[15],0,sizeof(number_key_str[15]));	
	
	number_key_str[0][0]='|';
	#if 0
	if(kodak_network_config.dhcp == 0){
		int ret;
		
		char ip_str[20];
		ret = netif_get_config(&temp_ifconfig);
              if (!ret){
                    if (temp_ifconfig.status)
                    {
                        /* Interface enabled. */
			   get_netconfig_flag = 1;
                        if (temp_ifconfig.ipaddr.s_addr)
			   {                        	
                            inet_ntoa_r(temp_ifconfig.ipaddr, ip_str);
				UpdateAddrArrange(ip_str);
                        }
                    	}
       	}
       }
       #endif
    	return 0 ;
}
INT32S NumberKeyBoardBarOnKeyPress(PHWND hwnd, INT32S lpParam)
{
	INT32U *key_value = (INT32U *)lpParam ;
	switch(*key_value)
	{
		case UOP_OSD:
			GUIShowWindow("WinHome");
			break;
		case UOP_RESUME:
		//case UOP_STOP:
			PressNumberKeyBackDone();
			break;
		case UOP_LEFT:
			if(focus_flag>0)
			{
		 		GetKeyLose(hwnd);
		 		focus_flag--;
		 		GetKeyFocus(hwnd);
			}
		 	break;
		 case UOP_RIGHT:
		 	if(focus_flag<12)
		 	{
		 		GetKeyLose(hwnd);
		 		focus_flag++;
		 		GetKeyFocus(hwnd);
		    	}
		 	break;
		 case UOP_DOWN:
		 	GetKeyLose(hwnd);
		 	if(focus_flag<1)
		 		focus_flag=5;
		 	else if(focus_flag<5)
				focus_flag+=5;
		        else if((focus_flag==5)||(focus_flag==6))
				focus_flag=10;
		        else if(focus_flag==7)
				focus_flag=11;
		 	else if(focus_flag<9)
				focus_flag+=3;
		 	else if(focus_flag<11)
				focus_flag=11;
		 	else
				focus_flag=12;
			GetKeyFocus(hwnd);
		 	break;
		 case UOP_UP:
		 	if(focus_flag<5)
		 		break;
		 	else if(focus_flag<10)
		 	{
				GetKeyLose(hwnd);
				focus_flag-=5;
				GetKeyFocus(hwnd);
		 	}
		 	else if(focus_flag<11)
		 	{
				GetKeyLose(hwnd);
				focus_flag-=4;
				GetKeyFocus(hwnd);
		 	}
		 	else if(focus_flag==11)
		 	{
				GetKeyLose(hwnd);
				focus_flag=7;
				GetKeyFocus(hwnd);
		 	}
		 	else
		 	{
		 		GetKeyLose(hwnd);
				focus_flag=9;
				GetKeyFocus(hwnd);
		 	}
		 	break;
		case UOP_ENTER:
		 	PressEnterDown(hwnd);	
			break;		 		
	}
    	return 0 ;
}
INT32S NumberKeyBoardBarOnPaint(PHWND hwnd, INT32S lpParam)
{  
	INT8U i;
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 0);
	PIXELVAL color_bk;
	color_bk=AWSetForeground(BLACK_COLOUR);
	for(i=1;i<59;i++)
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, i);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
	AWSetForeground(color_bk);
    	return 1 ;
}

INT32S WinNumberKeyBoardOnShow(PHWND hwnd, INT32S lpParam)
{
	//SetDefaultSlideShowFlag(0);
	osdsettpval(4,0xf);
	return 0;
}
INT32S WinNumberKeyBoardOnHide(PHWND hwnd, INT32S lpParam)
{
	//SetDefaultSlideShowFlag(1);
	return 0;
}
#endif
